The control statments (which implement a loop control structure) are highlighted in red:
LET COUNT = 1 ' DO WHILE COUNT <= 10 PRINT "Count is now", COUNT LET COUNT = COUNT + 1 LOOP PRINT "Done with the loop" ' END
A control structure
controls the order in
which statements are executed.
The statements being controlled are
contained inside some statements that bracket them.
In the above example, the statements that are
being controlled (called the body of the loop)
are contained inside the DO
and the LOOP
.
It is helpful for humans to use indenting
to show which statements are being controlled.
Here is another example:
PRINT "Enter the hour of the day 0-23" INPUT HOUR IF HOUR < 12 THEN PRINT "Good Morning" ELSE PRINT "Good Day" END IF END
If the user enters 13 (for 1pm) what will the program print?